const { formatTime } = require("../../utils/timeFormatter.js")

Component({
  properties: {
    value: { type: [String, Number], value: "" } // 支持数字和字符串
  },
  data: {
    display: ""
  },
  observers: {
    value(newVal) {
      if (newVal) {
        let ts = newVal
        if (typeof ts === "string" && /^\d+$/.test(ts)) {
          ts = parseInt(ts) // 数字字符串转为数字
        }
        this.setData({ display: formatTime(ts) })
      }
    }
  }
})
